<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<div>div</div>
<p>p</p>
<div>div</div>
<span>span</span>
<p>p</p>
<div>div</div>
</body>
<script>
    var divs = document.getElementsByTagName( 'div' );
    var ps = document.getElementsByTagName( 'p' );
    for ( var i = 0; i < divs.length; i++ ) {
        divs[ i].style.border = '1px solid red';
    };
    for ( var i = 0; i < ps.length; i++ ) {
        ps[ i ].style.border = '1px solid blue';
    };
</script>
</html>